<template>
  <div class="container">
    <div class="screen" ref="screen">
      <div class="top"><Top></Top></div>
      <div class="bottom">
        <div class="left">
          <Tourist class="tourist"></Tourist>
          <Age class="age"></Age>
          <Sex class="sex"></Sex>
        </div>
        <div class="center">中间</div>
        <div class="right">右侧</div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue'
import Top from './components/top/index.vue'
import Age from '@/view/screen/components/age/index.vue'
import Tourist from '@/view/screen/components/tourist/index.vue'
import Sex from '@/view/screen/components/sex/index.vue'

// 获取数据大屏展示盒子的dom元素
let screen = ref()
onMounted(() => {
  screen.value.style.transform = `scale(${getScale()}) translate(-50%,-50%)`
})
//定义大屏缩放比例
function getScale(w = 1920, h = 1080) {
  const ww = window.innerWidth / w
  const wh = window.innerHeight / h
  return ww < wh ? ww : wh
}
//监听视口变化
window.onresize = () => {
  screen.value.style.transform = `scale(${getScale()}) translate(-50%,-50%)`
}
</script>

<style lang="scss" scoped>
.container {
  width: 100vw;
  height: 100vh;
  background: url(./images/bg.png) no-repeat center center/cover;
  .screen {
    position: fixed;
    width: 1920px;
    height: 1080px;
    // background-color: darkcyan;
    left: 50%;
    top: 50%;
    transform-origin: left top;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    .top {
      position: fixed;
      top: 0;
      width: 100%;
      // height: 42px;
    }
    .bottom {
      flex: 1;
      display: flex;
      .left {
        width: 25%;
        position: absolute;
        bottom: 0;
        flex: 1;
        height: calc(100% - 40px);
        // background-color: orange;
        display: flex;
        flex-direction: column;
        .tourist {
          flex: 1.5;
          // background-color: red;
        }
        .age {
          flex: 1;
          background-color: blue;
        }
        .sex {
          flex: 1;
          background-color: #fff;
        }
      }
      .center {
        position: absolute;
        width: 50%;
        bottom: 0;
        height: calc(100% - 72px);
        left: 25%;
        background-color: aquamarine;
      }
      .right {
        position: absolute;
        bottom: 0;
        width: 25%;
        height: calc(100% - 40px);
        left: 75%;
        background-color: blueviolet;
      }
    }
  }
}
</style>
